package com.welsy.iter.vo.iter
{
	import com.welsy.iter.vo.iter.pattern.*;
	import com.welsy.iter.business.IterQNames;	
	
	[Bindable]	
	public class ModuleVO extends CourseItem
	{
	  public var courseId:String = "";
	  public var moduleId:String = "";
	  public var type:String = "";
      public var title:String = "";
	  public var position:String = "";
	  public var notes:String = "";
	  public var displayFeedback:String = "true";	
		
	  // The array of child elements
      private var _items:Array;

      public function ModuleVO() {
         _items = new Array();
      }
      
      public function setProperties(list:XMLList):void {      	
     	var moduleId:String = list.child(IterQNames.qnModuleID);
    	var moduleTitle:String = list.child(IterQNames.qnTitle);	  
    	var modulePos:String = list.child(IterQNames.qnPosition);
    	var moduleNotes:String = list.child(IterQNames.qnModuleNotes);
        var moduleDisplayFeddback:String = list.child(IterQNames.qnModuleDispalyFeedBack);
        this.moduleId = moduleId;
        this.title = moduleTitle;
        this.position = modulePos;
        this.notes = moduleNotes;
        this.displayFeedback = moduleDisplayFeddback;        
      }
      
      public function setPropertiesModule(module:Module):void {      	
     	var moduleId:String = module.moduleId;
    	var moduleTitle:String = module.title;	  
    	var modulePos:String = module.position;
    	var moduleNotes:String = module.notes;
        var moduleDisplayFeddback:String = module.displayFeedback;
        this.moduleId = moduleId;
        this.title = moduleTitle;
        this.position = modulePos;
        this.notes = moduleNotes;
        this.displayFeedback = moduleDisplayFeddback;        
      }

      override public function addItem(item:ICourseItem):void {
         _items.push(item);
      }

      override public function removeItem(item:ICourseItem):void {
         var i:uint;
         // Loop through all the child elements.
         for(i = 0; i < _items.length; i++) {
            // If one of the elements matches the 
            // parameter remove it from the array.
            if(_items[i] == item) {
               _items.splice(i, 1);
               break;
            }
         }
      }
      override public function iterator():ICourseIterator {
         
         return new ArrayCourseIterator(_items);
      }

	}
}